import gevent.monkey

gevent.monkey.patch_all()
import os

from tools.html2pdf import convert_html_to_pdf


def test_html_to_pdf():
    """Test function for HTML to PDF conversion."""
    # Read the index.html file
    with open("index.html", "r", encoding="utf-8") as f:
        html_content = f.read()

    # Convert HTML to PDF
    output_path = convert_html_to_pdf(html_content)

    if os.path.exists(output_path):
        file_size = os.path.getsize(output_path)
        print(
            f"Successfully converted HTML to PDF. Output file: {output_path}, Size: {file_size} bytes"
        )
        return True
    else:
        print(f"Failed to generate PDF file at {output_path}")
        return False


# Run the test if executed directly
if __name__ == "__main__":
    test_html_to_pdf()